package com.scoresystem.web.controller.dispatcher;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.scoresystem.common.CommonValue;
import com.scoresystem.web.service.StudentService;
import com.scoresystem.web.ui.bridge.ViewBridgeImpl;
import com.scoresystem.web.ui.view.ViewFactory;

import net.sf.json.JSONObject;

public class StudentDispatcher extends BaseDispatcher implements IDispatcher {

	private StudentService service;
	public StudentDispatcher(){
		showable=null;
		viewbridge=new ViewBridgeImpl();
		service=new StudentService();
	}
	@Override
	public void dispatch(String option, HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//查找自己的成绩
		if (option.equals(CommonValue.REQUEST_OP_QUERYSCORE)) {
			showable = ViewFactory.createShowStuScoreView();
			JSONObject json = service.checkoutScores(request.getParameter("stunum"));
			viewbridge.setShowable(showable).showView(json, request, response);
		}
		//提交反馈
		if(option.equals(CommonValue.REQUEST_OP_REMARK)){
			showable = ViewFactory.createShowStuRemarkView();
			JSONObject json = service.checkoutRemark
					(request.getParameter("stunum"), request.getParameter("worknum"),
							request.getParameter("remark"));
			viewbridge.setShowable(showable).showView(json, request, response);
		}
	}

}
